package com.ipc.admin.controller.zzcool;

import com.ipc.admin.service.zzcool.service.CouponService;
import com.ipc.common.pojo.vo.R;
import com.ipc.core.entity.zzcool.Coupon;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


/**
 * @author Zzcool
 * @create 2023-04-30 22:52
 */
@RestController
@RequestMapping(value = "/api/CouponController/", produces = "application/json; charset=utf-8")
@CrossOrigin
@Api(tags = "优惠卷项管理模块")
public class CouponController {
    @Resource
    private CouponService service;


    @ApiOperation("新增优惠卷项数据")
    @PostMapping("save")
    public R save(Coupon coupon) {
        return R.ok(service.save(coupon));
    }

    @ApiOperation("修改优惠卷项数据")
    @PostMapping("updateById")
    public R updateById(Coupon coupon) {
        return R.ok(service.updateById(coupon));
    }

    @ApiOperation("删除优惠卷项同时删除该项内优惠卷")
    @PostMapping("del")
    public R del(int id) {
        return R.ok(service.del(id));
    }

    @ApiOperation("发放优惠卷指明数量同时添加同等数量优惠卷")
    @PostMapping("giveOut")
    public R giveOut(Coupon coupon) {
        return R.ok(service.giveOut(coupon));
    }

    @ApiOperation("查询优惠卷项所有数据")
    @GetMapping("queryAll")
    public R queryAll() {
        return R.ok(service.selectAll());
    }

}
